#include <GameEngine/Graphics/Lighting/scene_light.h>

#include <GameEngine/Graphics/openGL.h>


#ifdef GAMEENGINE_NAMESPACES
namespace GameEngine {
#endif

//=====================================================================

Q_DECLARE_OPERATORS_FOR_FLAGS(Light::LightParameters)

//=================================================================================

//! Default constructor
SceneLight::SceneLight() : light_index_(0), Light(), SceneElement(LightElement) {}

//! Copy constructor
/*!
 @param rhs The light to copy
 */
SceneLight::SceneLight(const SceneLight& rhs) : light_index_(rhs.light_index_), Light(rhs), SceneElement(LightElement) {}

//! Destructor
SceneLight::~SceneLight() {}

//! Assignment operator
/*!
 @param rhs The light to copy
 */
SceneLight& SceneLight::operator=(const SceneLight& rhs) {
	if ( &rhs != this ) {
		Light::operator=(rhs);
		light_index_ = rhs.light_index_;
	}
	return *this;
}

//! Apply the light parameters to the scene
/*!
 *  The light is applied at given light index. This may interfere with other
 *  lights, if some of them share the same light index.
 *
 @param ray The picking ray under the mouse
 @return Always return true
 */
bool SceneLight::draw(const Line3d<float>& ray) {
	apply_light(light_index_);
	return true;
}

//! Accessor to the light index (read only)
/*!
 @return The light index. This index should NOT be shared with any other
         light of the scene
 */
int SceneLight::light_index() const {
	return light_index_;
}

//! Accessor to the light index (read-write)
/*!
 @return A reference to the light index. This index should NOT be shared with
         any other light of the scene
 */
int& SceneLight::light_index() {
	return light_index_;
}

//=================================================================================

#ifdef GAMEENGINE_NAMESPACES
} // namespace GameEngine
#endif
